const ffmpeg = require('fluent-ffmpeg');

const path = require('path')
const filePath = path.join(__dirname, '../public/video')
function videoSlice(input) {
    ffmpeg(path.join(filePath, input))
        .videoCodec('libx264')
        .format('hls')
        .outputOptions('-hls_list_size 5')
        .outputOptions('-hls_time 5')
        .output(path.join(filePath, 'output.m3u8'))
        .on('progress', (progress) => {
            console.log('Processing: ' + progress.percent + '% done');
        })
        .on('end', () => {
            console.log("视频切片完成");
        })
        .run()
}


videoSlice('demo.mp4')